package com.example.asus.a1127;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.view.animation.ScaleAnimation;
import android.widget.ImageView;

public class ScaleAnimActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_scale_anim);

        ImageView imageView= (ImageView) findViewById(R.id.msg);
        //给上面图片设置动画

        //给上面的图片设置动画，Activity是Context的子类
      //  Animation animation=AnimationUtils.loadAnimation(this,R.anim.scaleanim);
            //pivotX如果是正整数值，表示中心店事从左上角往右移动指定的像素值
          //Animation animation=new ScaleAnimation(0.1f,2f,0.1f,2f,200,200);
        //第五个参数是int privotXType有两种取值，1是自身，2是父容器，第七个参数是int privotYType
//        Animation animation=new ScaleAnimation(0.1f,1f,0.1f,1f,
//        Animation.RELATIVE_TO_PARENT,0.5f,Animation.RELATIVE_TO_PARENT,0.5f);
         Animation animation =new ScaleAnimation(0.1f,1f,0.1f,1f,-200,1400);
        animation.setDuration(6000);
        animation.setRepeatCount(2);//重复次数，本身播放的不算
        animation.setFillAfter(true);//FillAfter设置为true，表示动画播放完毕后会停留在最后一帧
        //在imageView上启动一个缩放动画
        imageView.startAnimation(animation);
    }
}
